<?php
namespace Admin\Controller;
use Think\Controller;
class PortController extends Controller {


    //联系我们
    public  function get_contact(){
        $result=M('contact')->where(array('id'=>1))->find();
        $this->ajaxReturn($result,'json');
    }

    //    舞蹈分页
    public function dance_more(){
        $pages=I('page')?I('page'):2;
        if($pages!=0){
            $pages=$pages-1;
        }
        $count=M('dance')->count();
        $page = new \Think\Page($count, 5);
        $page->show();   //分页数
        $all_page=$page->totalPages;//获取总行数
        $result = M('dance')->where()->limit($pages*$page->listRows . ',' . $page->listRows)->order('id ')->select();
        if($pages>=$all_page){
            $this->ajaxReturn(array('msg'=>'数据为空'),'json');
        }else{
            $this->ajaxReturn($result,'json');
        }
    }

    public function dance_data(){
        $data=M('dance')->order('id ')->limit(5)->select();
        $this->ajaxReturn($data,'json');
    }

    public function course_data(){
        $data=M('course')->order('id')->limit(5)->select();
        $this->ajaxReturn($data,'json');
    }

    public  function matching_dance($type,$id){
        if($type=='scene_type'){
            $data=M('dance')->where(array('scene_type'=>$id))->order('id ')->select();

        }else if($type=='dance_type'){
            $data=M('dance')->where(array('dance_type'=>$id))->order('id ')->select();
        }
        $this->ajaxReturn($data,'json');
    }

    public  function matching_course($type,$id){
        if($type=='difficulty_type'){
            $data=M('course')->where(array('difficulty_type'=>$id))->order('id ')->select();

        }else if($type=='dance_type'){
            $data=M('course')->where(array('dance_type'=>$id))->order('id ')->select();
        }
        $this->ajaxReturn($data,'json');
    }
    //课程分页
    public function course_more(){
        $pages=I('page')?I('page'):2;
        if($pages!=0){
            $pages=$pages-1;
        }
        $count=M('dance')->count();
        $page = new \Think\Page($count, 5);
        $page->show();   //分页数
        $all_page=$page->totalPages;//获取总行数
        $result = M('course')->where()->limit($pages*$page->listRows . ',' . $page->listRows)->order('id ')->select();
        if($pages>=$all_page){
            $this->ajaxReturn(array('msg'=>'数据为空'),'json');
        }else{
            $this->ajaxReturn($result,'json');
        }
    }

    //视频分页
    public function video_more(){
        $pages=I('page')?I('page'):2;
        if($pages!=0){
            $pages=$pages-1;
        }
        $count=M('video')->count();
        $page = new \Think\Page($count, 5);
        $page->show();   //分页数
        $all_page=$page->totalPages;//获取总行数
        $result = M('video')->where()->limit($pages*$page->listRows . ',' . $page->listRows)->order('id ')->select();
        if($pages>=$all_page){
            $this->ajaxReturn(array('msg'=>'数据为空'),'json');
        }else{
            $this->ajaxReturn($result,'json');
        }
    }

    public function video_data(){
        $data=M('video')->order('id')->limit(5)->select();
        $this->ajaxReturn($data,'json');
    }

}
